package com.sinux.generality.basesupport.utils.file;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.sinux.generality.basesupport.utils.tool.FileTool;
/**
 * 父文件对象
 * @ClassName BaseConf
 * @Description: 父文件对象
 * @author Tangjc
 * @date 2021年5月6日 下午3:18:10
 */
public class BaseConf {
	protected volatile Object paramsMap;
	
	public List<String> readPath(String path, String extension){
		return FileTool.getFileList(path, extension);
	}
	
    public List<String> readPath(String extension){
        return readPath(Constants.path, extension);
    }
    
    public <T> T getParamsMap(Class<T> cla){
    	return (T) paramsMap;
    }
    
    public String getKeyword(String resourcePath,String extension){
        Pattern p = Pattern.compile("(\\w+)."+extension);
        Matcher m = p.matcher(resourcePath);
        if(m.find()){
            String fileName = m.group(1);
            return format(m.group(1));
        }
        return null;
    }
    
    public String format(String source){
        StringBuffer sb = new StringBuffer();
        Matcher m = Pattern.compile("-([a-z])", Pattern.CASE_INSENSITIVE).matcher(source);
        while(m.find()){
            m.appendReplacement(sb, m.group().toUpperCase());
        }
        m.appendTail(sb);
        return sb.toString().replaceAll("-", "");
    }
    
}
